<template>
  <div class="goods-tabs">
    <nav>
      <a href="javascript:;" @click="activeCom='GoodsDetail'" :class="{active:activeCom==='GoodsDetail'}">商品详情</a>
      <a href="javascript:;" @click="activeCom='GoodsComment'" :class="{active:activeCom==='GoodsComment'}">商品评价
        <span v-if="goods.collectCount">({{goods.collectCount>500?'500+':'goods.collectCount'}})</span></a>
    </nav>
    <!-- 切换内容的地方 -->
    <keep-alive>
      <component :is='activeCom'/>
    </keep-alive>
  </div>
</template>

<script>
import { ref } from 'vue'
import GoodsComment from './goods-comment.vue'
import GoodsDetail from './goods-detail.vue'
export default {
  components: { GoodsDetail, GoodsComment },
  name: 'GoodsTabs',
  props: {
    goods: {
      type: Object,
      default: () => ({})
    }
  },
  setup () {
    const activeCom = ref('GoodsDetail')
    return { activeCom }
  }
}
</script>

<style lang="less" scoped>
.goods-tabs {
  min-height: 600px;
  background: #fff;
  nav {
    height: 70px;
    line-height: 70px;
    display: flex;
    border-bottom: 1px solid #f5f5f5;
    a {
      padding: 0 40px;
      font-size: 18px;
      position: relative;
      > span {
        color: @priceColor;
        font-size: 16px;
        margin-left: 10px;
      }
      &:first-child {
        border-right: 1px solid #f5f5f5;
      }
      &.active {
        &::before {
          content: "";
          position: absolute;
          left: 40px;
          bottom: -1px;
          width: 72px;
          height: 2px;
          background: @xtxColor;
        }
      }
    }
  }
}
</style>
